package design2.adapter.example;

import design2.adapter.example.adapters.SquarePegAdapter;
import design2.adapter.example.round.RoundHole;
import design2.adapter.example.round.RoundPeg;
import design2.adapter.example.square.SquarePeg;

public class Demo {

	public static void main(String[] args) {
		//半径为5的圆孔
		RoundHole roundHole=new RoundHole(5);

		RoundPeg roundPeg=new RoundPeg(5);
		if(roundHole.fits(roundPeg)){
			System.out.println("圆销钉r5适合圆孔r5。");
		}

		SquarePeg smallSqPeg=new SquarePeg(2);
		SquarePeg largeSqPeg=new SquarePeg(20);

		SquarePegAdapter smallSqPegAdapter=new SquarePegAdapter(smallSqPeg);
		SquarePegAdapter largeSqPegAdapter=new SquarePegAdapter(largeSqPeg);
		if(roundHole.fits(smallSqPegAdapter)){
			System.out.println("方形销钉w2适合圆孔r5。");
		}else{
			System.out.println("方形销钉w2不适合适合圆孔r5。");
		}

		if(roundHole.fits(largeSqPegAdapter)){
			System.out.println("方形销钉w20适合圆孔r5。");
		}else{
			System.out.println("方形销钉w20不适合圆孔r5。");
		}
	}
}
